<?php
/**
 * class App_View_Helper_PreReviewText
 *
 * @author kim
 */
class App_View_Helper_PreReviewText extends Zend_View_Helper_Abstract
{
    /**
     * returns admin review values in text
     *
     * @param string $text
     * @return array
     */
    public function PreReviewText($text)
    {
        $return = array();
        $text = App_Filter_Textarea::filter($text);
        $rows = substr_count($text, "\n") + floor(strlen($text)/60) + 1;
        if ($rows < 2) { $rows = 2; }
        if ($rows > 80) { $rows = 80; }
        $height = 20 * $rows;
        $deny = 0;
        $return['action'] = '';

        if (strlen($text) < 50) { $return['action'] = 'approve'; }

        if (preg_match("/(\@|href|img |http)/i",$text) || preg_match("/(fuck|piss|cock)/i",$text)) {
            $return['action'] = 'deny';
        }

        $return['bgcolor'] = '';
        if ($return['action'] == 'approve') { $return['bgcolor'] = 'CCFFCC'; }
        if ($return['action'] == 'deny') { $return['bgcolor'] = 'FFCCCC'; }

        $return['rows'] = $rows;
        return $return;
    }

}